const http = require("http");
const querystring = require("querystring");
const mysql = require("mysql");
const server = http.createServer((req,res)=>{

	if(req.url!='/favicon.ico'){
	}
		let postVal = "";
		req.on("data",(chunk)=>{
			postVal+=chunk;
		})
		req.on("end",()=>{
			
			let formVal = querystring.parse(postVal);
			let username = formVal.username;
			let password = formVal.password;


			const connection = mysql.createConnection({
				host: "127.0.0.1",
				user:'root',
				password:"123456",
				database:"wrh"
			})
			connection.connect();
			connection.query('insert into user value (?,?)',[username,password],(results,fields)=>{
				if(err) throw err;
				res.write("注册成功！！！");
				res.end();
			})
			connection.end();
		})
	}

)

server.listen(8080);